<% include ../common/header.ejs %>
</head>
<body>
    <% include ../common/nav.ejs %>
    <div class="container">
        <div class="row">
            <% include ../common/sidebar.ejs %>
            <div class="col-md-10">
                
                <ol class="breadcrumb">
                    <li><a href="#">主页</a></li>
                    <li><a href="#">栏目管理</a></li>
                    <li class="active">栏目列表</li>
                </ol>
                
                <%if(success){%>
                <div class="alert alert-success" role="alert"><%=success%></div>
                <%}%>
                <%if(error){%>
                <div class="alert alert-danger" role="alert">...</div>
                <%}%>
                <form class="form-inline" method="post" action="/admin/category/add">
                    <div class="form-group">
                        <label class="sr-only" for="exampleInputEmail3">栏目名</label>
                        <input name="cname" type="text" class="form-control" id="exampleInputEmail3" placeholder="栏目名">
                    </div>
                    
                    <div class="checkbox">
                        <label>
                        <input name="active" type="checkbox" value="1"> 是否显示
                        </label>
                    </div>
                    <button type="submit" class="btn btn-success">添加</button>
                </form>

                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>cid</th>
                            <th>栏目名</th>
                            <th>是否显示</th>
                            <th>操作</th>
                        </tr>
                    </thead>

                    <tbody>
                        <% for(var i=0;i<categories.length;i++){ %>
                        <tr>
                            <td><%=categories[i].cid%></td>
                            <td><%=categories[i].cname%></td>
                            <td><%if(categories[i].active==1){ %>显示 <%}else{%>不显示<%}%></td>
                            <td>
                                <a class="btn btn-success btn-xs" href="/admin/category/edit?cid=<%=categories[i].cid%>">编辑</a>
                                <a class="btn btn-danger btn-xs" href="">删除</a>
                                <a class="btn btn-primary btn-xs" href="/admin/article/add?cid=<%=categories[i].cid%>">添加文章</a>
                            </td>
                        </tr>
                        <%}%>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

<% include ../common/footer.ejs %>